package com.jr.service.impl;

import com.jr.dao.IUsersDao;
import com.jr.dao.IUsersEmployeesDao;
import com.jr.dao.impl.UserDaoImpl;
import com.jr.dao.impl.UsersEmployeesDaoImpl;
import com.jr.pojo.Users;
import com.jr.pojo2.UsersEmployees;
import com.jr.service.IUsersEmployeesService;
import com.jr.util.PageHelper;

import java.util.ArrayList;

public class UsersEmployeesServiceImpl implements IUsersEmployeesService {

    IUsersEmployeesDao iued =  new UsersEmployeesDaoImpl();
    IUsersDao iud = new UserDaoImpl();

    @Override // 分页查询 总条数
    public int queryPageDataCount() {
        return iued.selectPageDataCount();
    }

    @Override // 分页查询 查询当前页面 展示集合
    public ArrayList<UsersEmployees> queryIndexData(PageHelper ph) {
        return iued.selectIndexDate(ph);
    }

    @Override // 查询一条
    public UsersEmployees queryUsersEmployeesByUserName(String userName) {
        return iued.selectUsersEmployeesByUserName(userName);
    }

    @Override // 删除一条(在user里--前端的用户查询中)
    public boolean removeUsersByUserName(String userName) {
        ArrayList<Users> list = iud.selectUsersByName(userName);
        Users user = list.size()>0?list.get(0):null;
        if(user!=null){
            if(!user.getRole().equals("管理员")){//角色不是admin才能删
                return iud.deleteUsersByUserName(userName)>0?true:false;
            }
        }else{
            return false;
        }
        return false;
    }

    @Override
    public int queryPageDataCountByName(String search) {
        return iued.selectPageDataCountByUserName(search);
    }

    @Override
    public ArrayList<UsersEmployees> queryIndexDataByName(String search, PageHelper ph) {
        return iued.selectIndexDateByUserName(search,ph);
    }

/*    @Override
    public int queryPageDataCountByEmail(String email) {
        return iued.selectPageDataCountByEmail(email);
    }

    @Override
    public ArrayList<UsersEmployees> queryIndexDataByEmail(String email, PageHelper ph) {
        return iued.selectIndexDateByEmail(email,ph);
    }

    @Override
    public int queryPageDataCountByPhoneNum(String phoneNumber) {
        return iued.selectPageDataCountByPhoneNum(phoneNumber);
    }

    @Override
    public ArrayList<UsersEmployees> queryIndexDataByPhoneNum(String phoneNumber, PageHelper ph) {
        return iued.selectIndexDateByPhoneNum(phoneNumber,ph);
    }*/
}
